#pragma once

#include "Event.h"
#include "Sprite.h"
#include <list>
#include <queue>
#include <Windows.h>
#include <gl/GL.h>
#include <gl/GLU.h>

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")

#define WINDOWCLASS "RENDER_WINDOW"

class Renderer
{
public:
	static Renderer* GetInstance(void);
	static LRESULT CALLBACK WndProc(HWND hw, UINT msg, WPARAM wp, LPARAM lp);
	~Renderer(void);
	void SetWindow(char* title, int width, int height, int bpp, bool bFullScreen);
	void ToggleFullScreen(void);
	bool IsOpen(void);
	void DrawScene(void);
	void AddSprite(Sprite* sprite);
	void RemSprite(Sprite* sprite);
	bool GetEvent(Event* e);

private:
	Renderer(void);
	static Renderer* m_pInstance;
	static DWORD WINAPI StartThread(LPVOID pParam);
	void Initialize(void);
	void MsgLoop(void);
	HANDLE m_hThread;
	bool m_bInited;
	char* m_title;
	int m_width, m_height, m_bpp;
	bool m_bFullScreen;
	HWND m_hWnd;
	HDC m_hDC;
	HGLRC m_hRC;
	HDC m_hDCOld;
	HGLRC m_hRCOld;
	std::list<Sprite*> m_pSprites;
	std::queue<Event> m_Events;
};

